#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;

ll even(ll x)
{
	if (x % 10 % 2 == 0) { return x; }

	int c = -1;

	int sum = 0;

	while (x)
	{
		int y = x % 10;
		if (y % 2 == 0 && c == -1) { c == y; x /= 10; continue; }

		sum = sum * 10 + y;
		x /= 10;
	}

	if (c == -1)
	{
		return c;
	}

	sum = sum * 10 + c;

	return sum;
}

void Test1()
{
	int n; cin >> n;
	ll x;
	while (n--)
	{
		cin >> x;
		cout << even(x) << endl;
	}
}


int main()
{
	Test1();
	return 0;
}